$(document).ready(function() {
	var title;
	var x=Array();
	var y=Array();
	var ymax,ymin;
	var option = {};

function setopt(id){
	title="";
	x=Array();
	y=Array();
	ymax,ymin;
	option = {};

	$.ajax({      
		'url': "https://wx.jiao-xw.com/api/v1/pricelist",
		'async':false,
		'type': "post",
		"data": {
			'product_id': id,
      'date_limit': 200
     },
		'success': function(res) {        
			console.log(res);
			var arr = res.data.list;
			title = res.data.list[0].pro_name;
			ymax = res.data.max_value;
			ymin = res.data.min_value;
			for(i=0;i<arr.length;i++){
					x.push(arr[i].date);
					y.push(arr[i].price);
			}
		}    
	})

	option = {
		color: ["#007aff"],
		title: {
			text: title,
          subtext: "",
          textAlign: "left",
          x: "center",
          y: "top",
          top: 10,
          textStyle: {
            color: "#007aff",
            fontWeight: "400",
            fontSize: 14,
          },
          subtextStyle: { color: "#20a162", fontWeight: "100" },
		},
		tooltilp: {
			trigger: "axis",
			triggerOn: "mousemove",
			showContent: true,
		},
		legengd: {
			data: ["user from"]
    },
        tooltip: {
          trigger: "axis",
          triggerOn: "mousemove",
          showContent: true,
        },
		xAxis: {
			name:'日期',
			data: x,
			axisTick: {
				inside: true,
			},
		},
		yAxis: {
			name:'元/吨',
			scale:false,
			axisLine: {show:true},
			axisTick: {show:true},
			position:'left',
			max : ymax,
			min : ymin,
		},
		series: [{
			name: '价格:',
			type: 'line',
			symbol: 'circle',
			data: y
    }],
   };
}

	var myChart20 = echarts.init(document.getElementById('chartdialog20'));
	var myChart33 = echarts.init(document.getElementById('chartdialog33'));
	var myChart34 = echarts.init(document.getElementById('chartdialog34'));
	setopt(20);
	myChart20.setOption(option);
	setopt(33);
	myChart33.setOption(option);
	setopt(34);
	myChart34.setOption(option);

	var myChart1 = echarts.init(document.getElementById('chartdialog1'));
	var myChart2 = echarts.init(document.getElementById('chartdialog2'));
	var myChart3 = echarts.init(document.getElementById('chartdialog3'));
	var myChart4 = echarts.init(document.getElementById('chartdialog4'));
	var myChart5 = echarts.init(document.getElementById('chartdialog5'));
	var myChart6 = echarts.init(document.getElementById('chartdialog6'));
	var myChart7 = echarts.init(document.getElementById('chartdialog7'));
	var myChart8 = echarts.init(document.getElementById('chartdialog8'));
	var myChart9 = echarts.init(document.getElementById('chartdialog9'));
	var myChart10 = echarts.init(document.getElementById('chartdialog10'));
	var myChart11 = echarts.init(document.getElementById('chartdialog11'));
	var myChart12 = echarts.init(document.getElementById('chartdialog12'));
	var myChart13 = echarts.init(document.getElementById('chartdialog13'));
	var myChart14 = echarts.init(document.getElementById('chartdialog14'));
	var myChart15 = echarts.init(document.getElementById('chartdialog15'));
	var myChart16 = echarts.init(document.getElementById('chartdialog16'));
	setopt(1);
	myChart1.setOption(option);
	setopt(2);
	myChart2.setOption(option);
	setopt(3);
	myChart3.setOption(option);
	setopt(4);
	myChart4.setOption(option);
	setopt(5);
	myChart5.setOption(option);
	setopt(6);
	myChart6.setOption(option);
	setopt(7);
	myChart7.setOption(option);
	setopt(8);
	myChart8.setOption(option);
	setopt(9);
	myChart9.setOption(option);
	setopt(10);
	myChart10.setOption(option);
	setopt(11);
	myChart11.setOption(option);
	setopt(12);
	myChart12.setOption(option);
	setopt(13);
	myChart13.setOption(option);
	setopt(14);
	myChart14.setOption(option);
	setopt(15);
	myChart15.setOption(option);
	setopt(16);
	myChart16.setOption(option);

	var myChart21 = echarts.init(document.getElementById('chartdialog21'));
	var myChart22 = echarts.init(document.getElementById('chartdialog22'));
	var myChart23 = echarts.init(document.getElementById('chartdialog23'));
	var myChart24 = echarts.init(document.getElementById('chartdialog24'));
	var myChart25 = echarts.init(document.getElementById('chartdialog25'));
	var myChart26 = echarts.init(document.getElementById('chartdialog26'));
	var myChart27 = echarts.init(document.getElementById('chartdialog27'));
	var myChart28 = echarts.init(document.getElementById('chartdialog28'));
	var myChart29 = echarts.init(document.getElementById('chartdialog29'));
	var myChart30 = echarts.init(document.getElementById('chartdialog30'));
	var myChart31 = echarts.init(document.getElementById('chartdialog31'));
	var myChart32 = echarts.init(document.getElementById('chartdialog32'));
	setopt(21);
	myChart21.setOption(option);
	setopt(22);
	myChart22.setOption(option);
	setopt(23);
	myChart23.setOption(option);
	setopt(24);
	myChart24.setOption(option);
	setopt(25);
	myChart25.setOption(option);
	setopt(26);
	myChart26.setOption(option);
	setopt(27);
	myChart27.setOption(option);
	setopt(28);
	myChart28.setOption(option);
	setopt(29);
	myChart29.setOption(option);
	setopt(30);
	myChart30.setOption(option);
	setopt(31);
	myChart31.setOption(option);
	setopt(32);
	myChart32.setOption(option);

});
